package top.deepdesigner.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.deepdesigner.pojo.DtsGoodsSpecification;
import top.deepdesigner.service.DtsGoodsSpecificationService;

import java.util.Date;
import java.util.List;

/**
 * Start up <br/>
 * Created with IntelliJ IDEA. <br/>
 * Project Name: shop_manage <br/>
 * Author: duanruiqing <br/>
 * DateTime: 2022/9/24 星期六 11:20:57 <br/>
 */
@Service
public class DtsGoodsSpecificationServiceImpl extends ServiceImpl<BaseMapper<DtsGoodsSpecification>, DtsGoodsSpecification> implements DtsGoodsSpecificationService {
  @Override
  public List<DtsGoodsSpecification> getGoodsSpecificationByGoodId(Long id) {
    LambdaQueryWrapper<DtsGoodsSpecification> wrapper = new LambdaQueryWrapper<>();
    wrapper.eq(DtsGoodsSpecification::getGoodsId, id);
    return this.list(wrapper);
  }

  @Override
  @Transactional
  public void deleteGoodsSpecification(Integer goodsId) {
    LambdaQueryWrapper<DtsGoodsSpecification> wrapper = new LambdaQueryWrapper<>();
    wrapper.eq(DtsGoodsSpecification::getGoodsId, goodsId);
    DtsGoodsSpecification specification = new DtsGoodsSpecification();
    specification.setDeleted(true);
    specification.setUpdateTime(new Date());
    this.update(specification, wrapper);
  }
}
